package pms.controller;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.ModelAndView;



/** 
 * Controller to generate the Home Page basics to be rendered by a view. 
 * It extends the convenience class AbstractController that encapsulates most 
 * of the drudgery involved in handling HTTP requests. 
 * @author josef@dr-schneeberger.de
 */
public class SaveRennen extends AlleRennen {
	protected ModelAndView handleRequestInternal(
			HttpServletRequest httpServletRequest,
			HttpServletResponse httpServletResponse) throws Exception {
		httpServletRequest.setCharacterEncoding("UTF-8");
		int id = Integer.parseInt(httpServletRequest.getParameter("id"));
		String renndatum = httpServletRequest.getParameter("renndatum");
		String rennort = httpServletRequest.getParameter("rennort");
		String bezeichnung = httpServletRequest.getParameter("bezeichnung");
		String busplatz = httpServletRequest.getParameter("busplatz");

		
		if (id == 0) {
			getRennenDao().create(renndatum, rennort, bezeichnung, busplatz);
		} else {
			getRennenDao().modify(id, renndatum, rennort, bezeichnung, busplatz);
		}
		return super.handleRequestInternal(httpServletRequest, httpServletResponse);
	}

}
